
#include "leftPanel.h"


 leftPanel::leftPanel(HGE * _hge)
{
    
	tileset[0] = new hgeSprite(_hge->Texture_Load("images/frame1.png"), 0, 0, 32, 320);
	tileset[1] = new hgeSprite(_hge->Texture_Load("images/fence.png"), 0, 0, 120, 160);
	tileset[2] = new hgeSprite(_hge->Texture_Load("images/scaffold.png"), 0, 0, 120, 240);
	tileset[3] = new hgeSprite(_hge->Texture_Load("images/crates.png"), 0, 0, 120, 40);
	tileset[4] = new hgeSprite(_hge->Texture_Load("images/grids_colors.png"), 0, 0, 138, 138);
	typeOfShape=-1;
    setNumber=0;
	buttonStatus=false;
	TileNumber=-1;
}
 

bool leftPanel::selectTileOnTileSet()
{
	if((x<=128)&&(y<=320)&&(x>=0)&&(y>0))
	{
     TileNumber=(SGridY-1)*5+SGridX; 
     return true;
	}
return false;
}

 bool leftPanel::SelectTile(float _mouseX,float _mouseY,float tileSize)
{
	int mouseX,mouseY;

	 mouseX=_mouseX;
     mouseY=_mouseY;
	 GridX=(mouseX)/tileSize;

	 GridY=(mouseY)/tileSize;

 return 0;
}
bool leftPanel::getTileValue(int _x,int _y,int tSize,HGE * _hge)
{
    x=_x-_x%tSize;
	y=_y-_y%tSize;
	 
	SGridX=_x/tSize;
	SGridY=_y/tSize;
	
	return true;
}
 bool leftPanel::DrawLines(HGE * _hge)

 {
	//if((x<=128)&&(y<=320)&&(x>=0)&&(y>0))
	{
	/* _hge->Gfx_RenderLine(x,y,x+32,y,0xFFFFFFFF,0.5f);
	 _hge->Gfx_RenderLine(x+32,y,x+32,y+32,0xFFFFFFFF,0.5f);
	 _hge->Gfx_RenderLine(x+32,y+32,x,y+32,0xFFFFFFFF,0.5f);
	 _hge->Gfx_RenderLine(x,y+32,x,y,0xFFFFFFFF,0.5f);*/
	 
	
	}
	//else return false;
	 return 0;
 }
 bool leftPanel::DrawTileSet(int _setNumber)
 {
    tileset[_setNumber]->Render(0,32);
    return true;
 }


 bool leftPanel::changeTileSet(bool next)
 {
   if(next==true)
    setNumber++;
   else
    setNumber--;

   if(setNumber<0)
    setNumber=0;
   if(setNumber>4)
    setNumber=4;
    
   
	return true;
 }
bool leftPanel::addMainField(float _mainX_Position,float _mainY_Position,hgeSprite mainFieldSprite) 
{
 mainX_Position=_mainX_Position;
 mainY_Position=_mainY_Position;
 mainFieldSprite.Render(mainX_Position,mainY_Position);
 
 return true;
}

bool leftPanel::addGridToField(int _HEIGHT,int _WIDTH,HGE * _hge)
{ 
	for(int i=0;i<=_HEIGHT;i++)
	   {
        _hge->Gfx_RenderLine(160,32*i,800,32*i,0xFF00FFFF,0.5f);
	   }
	
  for(int i=0;i<=_WIDTH;i++)
	   {
        _hge->Gfx_RenderLine(160+32*i,0,160+32*i,600,0xFF00FFFF,0.5f);
	   }
	

	return true;
}

int leftPanel::selectType(int x,int y)

{

//typeOfShape=-1;
	if((y>32)&&(y<=64))
	{
	 if (x >= 2 && x <=38 )
	 {
		typeOfShape=0;
        return 1;
	 }
	 if (x >= 42 && x <= 78)
	 {
	    typeOfShape=1;
		return 1;
	 }
	 if (x >= 82 && x <= 118)
	 {
		typeOfShape=2;
		return 1;
	 }

	 if (x >= 122 && x <= 158)
	 {
		typeOfShape=3;
		return 1;
 	 } 
	}
	return 0;
}